package com.example.service.impl;

import com.example.entity.User;
import com.example.mapper.UserMapper;
import com.example.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class UserServiceImpl implements UserService {

    private final UserMapper userMapper;

    @Override
    public User getUserWithRolesByUsername(String username) {
        return userMapper.selectUserWithRolesByUsername(username);
    }

    @Override
    public List<User> searchUsersWithRolesAndMenus(String username, String email, Integer status) {
        return userMapper.selectUsersWithRolesAndMenusByCondition(username, email, status);
    }

    @Override
    public List<User> getAllUsers() {
        return userMapper.selectAllUsers();
    }

    @Override
    public User getUserDetailWithRolesAndMenus(String username) {
        // 这里可以组合多个查询来获取完整的用户信息
        User user = userMapper.selectUserWithRolesByUsername(username);
        // 如果需要菜单信息，可以额外查询
        return user;
    }
}